version: '3'

services:
  broker-service:
    build:
      context: ./../broker-service
      dockerfile: ./../broker-service/broker-service.dockerfile
    restart: always
    ports:
      - "8080:80"
    deploy:
      mode: replicated
      replicas: 1

  logger-service:
    build:
      context: ./../logger-service
      dockerfile: ./../logger-service/logger-service.dockerfile
    restart: always
    deploy:
      mode: replicated
      replicas: 1

  mail-service:
    build:
      context: ./../mail-service
      dockerfile: ./../mail-service/mail-service.dockerfile
    restart: always
    deploy:
      mode: replicated
      replicas: 1
    environment:
      MAIL_DOMAIN: localhost
      MAIL_HOST: mailhog
      MAIL_PORT: 1025
      MAIL_ENCRYPTION: none
      MAIL_USERNAME: ""
      MAIL_PASSWORD: ""
      FROM_NAME: "John Smith"
      FROM_ADDRESS: john.smith@example.com

  authentication-service:
    build:
      context: ./../authentication-service
      dockerfile: ./../authentication-service/authentication-service.dockerfile
    restart: always
    ports:
      - "8081:80"
    deploy:
      mode: replicated
      replicas: 1
    environment:
      DSN: "host=postgres port=5432 user=postgres password=postgres dbname=users sslmode=disable timezone=UTC connect_timeout=5"

  listener-service:
    build:
      context: ./../listener-service
      dockerfile: ./../listener-service/listener-service.dockerfile
    deploy:
      mode: replicated
      replicas: 1

  postgres:
    image: 'postgres:14.0'
    ports:
      - "5432:5432"
    restart: always
    deploy:
      mode: replicated
      replicas: 1
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: users
    volumes:
      - ./db-data/postgres/:/var/lib/postgresql/data/

  mongo:
    image: 'mongo:4.2.16-bionic'
    ports:
      -  "27017:27017"
    environment:
      MONGO_INITDB-DATABASE: logs
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: password
    volumes:
      - ./db-data/mongo:/data/db

  maillog:
    image: 'mailhog/mailhog:latest'
    ports:
      -  "1025:1025"
      - "8025:8025"

  rabbitmq:
    image: 'rabbitmq:3.9-alpine'
    ports:
      - "5672:5672"
    deploy:
      mode: replicated
      replicas: 1
    volumes:
      - ./db-data/rabbitmq/:/var/lib/rabbitmq/